package com.ruoyi.syf.controller;

import java.util.List;

import com.ruoyi.syf.domain.RiskCheckDangerDetect;
import com.ruoyi.syf.domain.vo.RiskCheckDangerDetectVo;
import com.ruoyi.syf.service.IRiskCheckDangerDetectService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隐患整改验收
 *
 * @author yr
 * @date 2024-08-03
 */
@RestController
@RequestMapping("/syf/detect")
public class RiskCheckDangerDetectController extends BaseController {
    @Autowired
    private IRiskCheckDangerDetectService riskCheckDangerDetectService;

    /**
     * 查询隐患整改验收列表
     */
    @GetMapping("/list")
    public TableDataInfo list(RiskCheckDangerDetect riskCheckDangerDetect) {
        startPage();
        List<RiskCheckDangerDetectVo> list = riskCheckDangerDetectService.list(riskCheckDangerDetect);
        return getDataTable(list);
    }

    /**
     * 获取隐患整改验收详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return success(riskCheckDangerDetectService.getInfo(id));
    }

    /**
     * 整改验收
     */
    @PreAuthorize("@ss.hasPermi('syf:detect:edit')")
    @Log(title = "隐患整改验收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RiskCheckDangerDetect riskCheckDangerDetect) {
        return toAjax(riskCheckDangerDetectService.await(riskCheckDangerDetect));
    }

    /**
     * 删除隐患整改验收
     */
    @PreAuthorize("@ss.hasPermi('syf:detect:remove')")
    @Log(title = "隐患整改验收", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(riskCheckDangerDetectService.deleteRiskCheckDangerDetectByIds(ids));
    }
}
